﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;
using Spinning.Spinning.EntityModifiers;
using Spinning.Spinning.Level;
using Microsoft.Xna.Framework.Input.Touch;

namespace Spinning.Spinning.Entity.Scenes
{
    abstract class TeachScene : Scene
    {
        int _gameTime;
        protected List<Sprite> _sprites = new List<Sprite>();
        protected Sprite spriteText;
        public override void OnLoad()
        {
            base.OnLoad();

            ButtonSprite startSprite = new ButtonSprite();
            startSprite.textureName = "teachWater/start";
            startSprite.ZIndex = Constants.ui;
            startSprite.Position = new Vector2(0, Constants.Window_Height - 107);
            startSprite.OnLoad();
            TouchManager.RegisteTouchArea(startSprite);
            this.Attach(startSprite);

            startSprite.OnTouchEvent += OnStartTouch;

        }

        void OnStartTouch(BaseEntity entity, TouchLocation touchLocation)
        {
            OnStartFunction();
        }

        public abstract void OnStartFunction();

        protected override void UpdateSelf(GameTime gameTime)
        {
            base.UpdateSelf(gameTime);
            int delta = gameTime.ElapsedGameTime.Milliseconds;
            _gameTime += delta;
            if (_gameTime / 500 >= 1)
            {
                _gameTime = _gameTime % 500;
                DoChangeSprite();
            }
        }

        int temp;

        protected virtual void DoChangeSprite()
        {
            _sprites[temp].Alpha = 0;
            temp++;
            if (temp == _sprites.Count) temp = 0;
            _sprites[temp].Alpha = 1;
        }

    }
}
